import { ref } from 'vue'
import NeoVis, { NeovisConfig } from 'neovis.js'

// const query = ref('MATCH p=()-[r:SAYS]->() RETURN p LIMIT 25')
const query = ref('match(n) return n limit 100')

const neoConfig: NeovisConfig = {
    containerId: 'my-neo-vis',
    // 服务器地址
    // 用户名
    // server_url: import.meta.env.VITE_NEO_SERVER_URL,
    // server_user: import.meta.env.VITE_NEO_SERVER_USER,
    // server_password: import.meta.env.VITE_NEO_SERVER_PASSWORD,
    // neo4j: GLOBAL_NEO_CONFIG,
    neo4j: GLOBAL_NEO_CONFIG,
    visConfig: {
        nodes: {
            shape: 'box',
            font: '10px',
            size: 20,
            scaling: {
                max: 5,
                min: 2,
            },
            color: {
                highlight: '#2B7CE9',
            },
        },
        edges: {
            // labelHighlightBold: true,
            // color:'red',
            arrows: {
                to: {
                    enabled: true,
                    scaleFactor: 0.5,
                    type: 'arrow',
                },
            },
            chosen: {
                label: true,
            },
            physics: true,
            arrowStrikethrough: true,
            selfReference: {
                size: 10,
            },

            color: {
                highlight: '#2B7CE9',
            },
        },
        physics: {
            enabled: true,
            barnesHut: {
                theta: 0.5,
                gravitationalConstant: -2000,
                centralGravity: 0.3,
                springLength: 95,
                springConstant: 0.04,
                damping: 0.09,
                avoidOverlap: 0,
            },
            forceAtlas2Based: {
                theta: 0.5,
                gravitationalConstant: -100,
                centralGravity: 0.01,
                springLength: 1000,
                springConstant: 0.02,
                damping: 0.4,
                avoidOverlap: 1000,
            },
            repulsion: {
                nodeDistance: 100,
            },
            solver: 'barnesHut',
            // // 如果为true，则使用默认设置在加载时稳定关系图。如果为false，则禁用稳定。可以使用stabilization对象自定义。
            stabilization: {
                enabled: true,
                iterations: 1000,
                updateInterval: 50,
                onlyDynamicEdges: false,
                fit: true,
            },
            // timestep:0.5,
            // // adaptiveTimestep:true,
            // // wind:{

            // // },
        },
    },

    relationships: {
        [NeoVis.NEOVIS_DEFAULT_CONFIG]: {
            [NeoVis.NEOVIS_ADVANCED_CONFIG]: {
                function: {
                    label: (rel: any) => {
                        return rel.type
                    },
                },
            },
        },
    },
    nonFlat: false,
    labels: {
        [NeoVis.NEOVIS_DEFAULT_CONFIG]: {
            caption: 'name',
            label: 'name',
            // title_properties: 'name',
        },
        Entity: {
            // size:'20px',
        },
    },
    initialCypher: 'MATCH (p)-[r]->(n) RETURN p LIMIT 25',
}

export default {
    query,
    neoConfig,
}
